\section{ Dynamic IP routing using OSPF}
\graphicspath{{./figures/OSPF}}
In this scenario, called OSPF, the network level makes use of the routing protocol (in our case OSPF) to recover from failures. 

At first we decided to use an exponential departure time but then we decided to use a constant departure time for the source.
This choice was made in order to clearly show the packet loss in the results.
Obviously an exponential departure time would have been more realistic, but this is not relevant given the scope of out test.
Figure \ref{fig:OSPF_traffic} shows the differences of the two approaches.
Since OSPF convergence at the beginning of the simulation takes approximately one minute, traffic is sent from the source after 200 seconds.

\begin{figure}[!htbp]
\centering
\subfigure{\includegraphics[width=0.45\textwidth]{./figures/OSPF/OSPF_sent_rcv_exp.pdf}
\label{OSPF_traffic_exp} }
\subfigure{\includegraphics[width=0.51\textwidth]{./figures/OSPF/OSPF_sent_rcv_const.pdf} 
\label{OSPF_traffic_const}}
\caption{Figure \ref{OSPF_traffic_exp} shows the traffic in the case of exponential distribution while Figure \ref{OSPF_traffic_const} shows the traffic in the case of a constant distribution. }
\label{fig:OSPF_traffic}
\end{figure}

As a next step we simulated a failure in the link between the node 1 and the node 2 after 500 seconds from the beginning of the simulation.

\begin{figure}[!htbp]
\centering
\includegraphics[width=\textwidth]{./figures/OSPF/OSPF_conv.pdf} 
\caption{ The first graph shows the traffic dropped in the whole IP network.
The second graph shows the convergence activity of OSPF while the last one shows the traffic received from the destination. }
\label{OSPF_link_failure}
\end{figure}

By using constant departure time at the source is perfectly clear the time instant of the failure and the consequent convergence of OSPF.
The first graph shows the traffic lost due to the failure between node 1 and node 2.
The link failure is immediately detected and, after the convergence activity of OSPF (Graph 2), a new route from source to destination is available and traffic is restored.
%BETTER EXPLANATION HERE
We can say that the recovery time collide with the convergence time of OSPF which is, approximately, 15 seconds (Figure \ref{OSPF_link_failure}).
We executed multiple simulations entering multiple seeds values in order to find a confidence interval for the recovery time.
The recovery time vary very slightly so no confidence interval is shown.

\subsection{Node failures in OSPF}

In the scenario we wanted to test the recovery time of OSPF with respect of node failures.

\begin{figure}[!htbp]
\centering
\includegraphics[width=\textwidth]{./figures/OSPF/OSPF_node_failure.pdf} 
\caption{ in red the convergence time of OSPF, in blue OSPF convergence activity,in green IP traffic received in the destination}
\label{fig:OSPF_node_failure}
\end{figure}

In order to simulate the node failure we had to modify the type of failure in the Failure Recovery object, from link failure to node failure.
After 500 seconds from the start of the simulation node 2 stops to process packets and stops sending Hello packets to neighbor routers.
In this scenario, the convergence time is about 15 second, but it  also take some time to detect the failure.
This interval of time is the RouterDeadInterval and corresponds to the time of four hello packets intervals.
So a router is considered down only after not having received 4 consecutive hello packets (40 seconds).
 We can see in Figure \ref{fig:OSPF_node_failure} that more traffic is lost with respect to the previous scenario since the recovery time is
 $$T_{rcv} = T_{DRI} + T_{conv}$$ 
which correspond to the RouterDeadInterval plus the convergence time of OSPF.
A thing that we could not explain with certainty is the double convergence activity of OSPF at the start up of the simulation.
We think that the first phase is the establishment of adjacency and election of designated routers while the second phase is the actual exchange of database entries.